/*
 * Project Name spring-boot-tools
 * File Name LauncherService
 * Package Name com.huxiaosu.tools.common.service
 * Create Time 2024/4/18
 * Create by name：liujie
 */
package com.huxiaosu.tools.common.service;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.Ordered;

/**
 * 启动前 可以自定义的一些操作
 *
 * @author liujie
 * @date 2024/4/18 22:40
 */
public interface LauncherService extends Ordered, Comparable<LauncherService> {

    /**
     * 启动时 处理 SpringApplicationBuilder
     * @param builder SpringApplicationBuilder
     * @param appName SpringApplicationAppName
     */
    void launcher(SpringApplicationBuilder builder, String appName);

    /**
     * 获取排列顺序
     * @return order
     */
    @Override
    default int getOrder() {
        return Ordered.HIGHEST_PRECEDENCE;
    }

    /**
     * 对比排序
     * @param o LauncherService
     * @return compare
     */
    @Override
    default int compareTo(LauncherService o) {
        return Integer.compare(this.getOrder(), o.getOrder());
    }

}
